package com.sirc.zp.mapper;

import com.sirc.zp.domain.User;
import com.sirc.zp.sqlprovider.UserProvider;
import org.apache.ibatis.annotations.*;

@Mapper
public interface UserMapper {
    /**
     * 通过用户名得到User实体
     * @param username
     * @return
     */
    @SelectProvider(type=UserProvider.class, method="getUserByName")
    public User getUserByName(String username);
    /**
     * 通过id得到User实体
     * @param id
     * @return
     */
    @SelectProvider(type=UserProvider.class, method="getUserById")
    public User getUserById(Integer id);
    /**
     * 增加用户
     * @param user
     * @return
     */
    @SelectKey(statement = "select last_insert_id()", keyProperty = "uid", before = false, resultType = int.class)
    @InsertProvider(type=UserProvider.class, method="addUser")
    public Integer addUser(User user);
    /**
     * 更新用户
     * @param user
     * @return
     */
    @UpdateProvider(type=UserProvider.class, method="updateUser")
    public Integer updateUser(User user);

    /**
     * 删除用户信息
     * @param id
     * @return
     */
    @DeleteProvider(type=UserProvider.class, method="deleteUser")
    public Integer deleteUser(Integer id);
}
